package br.com.intelsys.basics.dao;

public abstract class DaoException extends Exception {
	private static final long serialVersionUID = 296862841801413062L;
	private int errorMessageCode;
	private String errorMessage;

	public DaoException(Exception e) {
		this.errorMessage = e.getMessage();
		this.errorMessageCode = -1;
	}

	public DaoException(int errorMessageCode, String errorMessage) {
		this.errorMessageCode = errorMessageCode;
		this.errorMessage = errorMessage;
	}

	@Override
	public String getMessage() {
		StringBuilder sb = new StringBuilder(32);
		sb.append('(');
		sb.append(this.errorMessageCode);
		sb.append(')');
		sb.append(' ');
		sb.append(this.errorMessage);
		return (sb.toString());
	}

	public int getErrorMessageCode() {
		return (errorMessageCode);
	}

	public void setErrorMessageCode(int errorMessageCode) {
		this.errorMessageCode = errorMessageCode;
	}

	public String getErrorMessage() {
		return (errorMessage);
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

	public abstract boolean isConstraintViolation();
}
